package com.ebt.m.proposal_v2.utils;

import android.os.Environment;
import android.widget.Toast;

import com.ebt.m.utils.*;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;

/**
 * Created by Rick.Wang on 2017/11/14.
 */

public class LogUtils {

    public static String saveToSd(String content, String namePrefix){
        File sdCardDir = Environment.getExternalStorageDirectory();//获取SDCard目录,2.2的时候为:/mnt/sdcart  2.1的时候为：/sdcard，所以使用静态方法得到路径会好一点。
        Date date = new Date();
        String dateTime = com.ebt.m.utils.DateUtils.dateTime2String(date);
        File saveFile = new File(sdCardDir, namePrefix + dateTime + ".txt");
        try {
            FileOutputStream outStream = new FileOutputStream(saveFile);
            outStream.write(content.getBytes());
            outStream.close();

        }catch (Exception e){

        }
        return saveFile.getAbsolutePath();
    }
}
